package com.knife.bbs.object;

import java.util.Date;

import com.knife.bbs.business.BBSDirService;

/**
 * BBS用户信息-通过实现IObject接口支持KnifeDBO零配置文件方式映射
 * 
 */
public class UserInfo {
	private String cid;
	private String username;
	private String password;
	private String sex;
	private String email;
	private String tel;
	private Integer logintimes;
	private Date inputtime;
	private String intro;
	private Integer status;
	private Date lastlogintime;
	private String lastloginip;
	private String photo;
	private String qq;
	private Integer score;
	private String role;
	
	private BBSDirService dirService = new BBSDirService();

	public String getCid() {
		return cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public Date getInputtime() {
		return inputtime;
	}

	public void setInputtime(Date inputTime) {
		this.inputtime = inputTime;
	}

	public String getLastloginip() {
		return lastloginip;
	}

	public void setLastloginip(String lastLoginIP) {
		this.lastloginip = lastLoginIP;
	}

	public Date getLastlogintime() {
		return lastlogintime;
	}

	public void setLastlogintime(Date lastLoginTime) {
		this.lastlogintime = lastLoginTime;
	}

	public Integer getLogintimes() {
		return logintimes;
	}

	public void setLogintimes(Integer loginTimes) {
		this.logintimes = loginTimes;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String userName) {
		this.username = userName;
	}

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public UserInfo(com.knife.bbs.domain.UserInfo user) {
		this.cid = user.getCid();
		this.username = user.getUsername();
		this.password = user.getPassword();
		this.sex = user.getSex();
		this.email = user.getEmail();
		this.tel = user.getTel();
		this.logintimes = user.getLogintimes();
		this.inputtime = user.getInputtime();
		this.intro = user.getIntro();
		this.status = user.getStatus();
		this.lastlogintime = user.getLastlogintime();
		this.lastloginip = user.getLastloginip();
		this.photo = user.getPhoto();
		this.qq = user.getQq();
		this.score = user.getScore();
	}

	public String getRoleName(String sn) {
		if (sn == null || "".equals(sn)) {
			return "";
		}
		BBSDir dir=dirService.getBBSDirBySN(sn);
		if (dir.getManager() != null) {
			if (dir.getManager().trim().equals(this.getUsername().trim())) {
				return "版主";
			}
		}
		if (dir.getSubmanager() != null) {
			if (dir.getSubmanager().trim().equals(this.getUsername().trim())) {
				return "副版主";
			}
		}
		return "注册用户";
	}
}
